USE [master]
GO
--********************* DB ************************
--********************* DB ************************
--********************* DB ************************
--********************* DB ************************
GO
/****** Object:  Database [ServCons_Integrado]    Script Date: 01/16/2011 01:49:08 ******/
CREATE DATABASE [ServCons_Integrado] ON  PRIMARY 
( NAME = N'ServCons_Integrado', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ServCons_Integrado.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'ServCons_Integrado_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ServCons_Integrado_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
GO
EXEC dbo.sp_dbcmptlevel @dbname=N'ServCons_Integrado', @new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [ServCons_Integrado].[dbo].[sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [ServCons_Integrado] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET ARITHABORT OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [ServCons_Integrado] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [ServCons_Integrado] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [ServCons_Integrado] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET  ENABLE_BROKER 
GO
ALTER DATABASE [ServCons_Integrado] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [ServCons_Integrado] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [ServCons_Integrado] SET  READ_WRITE 
GO
ALTER DATABASE [ServCons_Integrado] SET RECOVERY FULL 
GO
ALTER DATABASE [ServCons_Integrado] SET  MULTI_USER 
GO
ALTER DATABASE [ServCons_Integrado] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [ServCons_Integrado] SET DB_CHAINING OFF 
GO
--********************* TABLAS ************************
--********************* TABLAS ************************
--********************* TABLAS ************************
--********************* TABLAS ************************
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_PlanServicio]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_PlanServicio](
	[Co_Plan] [int] IDENTITY(1,1) NOT NULL,
	[No_Anio] [varchar](4) NOT NULL,
	[No_Mes] [varchar](2) NOT NULL,
	[Tx_Descripcion] [varchar](255) NULL,
 CONSTRAINT [PK_T_SER_ESI_PlanServicio44] PRIMARY KEY NONCLUSTERED 
(
	[Co_Plan] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_Persona]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_Persona](
	[Co_Persona] [int] NOT NULL,
	[Tx_Direccion] [varchar](255) NOT NULL,
	[Tx_Telefono] [varchar](255) NOT NULL,
	[Tx_Email] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_Persona49] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_TipoServicio]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_TipoServicio](
	[Co_TipoServicio] [int] IDENTITY(1,1) NOT NULL,
	[Tx_TipoServicio] [varchar](255) NULL,
	[Fl_Activo] [bit] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_TipoServicio54] PRIMARY KEY NONCLUSTERED 
(
	[Co_TipoServicio] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Alternativa]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Alternativa](
	[Co_Alternativa] [int] IDENTITY(1,1) NOT NULL,
	[No_Alternativa] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Alternativa61] PRIMARY KEY NONCLUSTERED 
(
	[Co_Alternativa] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Contrato]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Contrato](
	[Co_Contrato] [int] IDENTITY(1,1) NOT NULL,
	[Co_Expediente] [int] NOT NULL,
	[Tx_Numero] [varchar](255) NOT NULL,
	[Fe_Inicio] [datetime] NOT NULL,
	[Fe_Fin] [datetime] NOT NULL,
	[Tx_RutaContrato] [varchar](255) NULL,
	[Ss_Monto] [money] NOT NULL,
	[Tx_Observacion] [varchar](255) NULL,
	[No_Estado] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Contrato39] PRIMARY KEY NONCLUSTERED 
(
	[Co_Contrato] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [TC_T_SER_ESI_Contrato96] UNIQUE NONCLUSTERED 
(
	[Co_Expediente] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Encuesta]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Encuesta](
	[Co_Encuesta] [int] IDENTITY(1,1) NOT NULL,
	[No_Titulo] [varchar](255) NOT NULL,
	[Fe_Fecha] [datetime] NOT NULL,
	[No_Estado] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Encuesta41] PRIMARY KEY NONCLUSTERED 
(
	[Co_Encuesta] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_INF_Ambiente]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_INF_Ambiente](
	[Co_Ambiente] [smallint] NOT NULL,
	[No_Ambiente] [smallint] NOT NULL,
 CONSTRAINT [PK_T_INF_Ambiente46] PRIMARY KEY NONCLUSTERED 
(
	[Co_Ambiente] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_COM_Producto]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_COM_Producto](
	[Co_Producto] [smallint] NOT NULL,
	[No_Producto] [smallint] NOT NULL,
	[No_UnidadMedida] [smallint] NOT NULL,
	[Ss_Precio] [smallint] NOT NULL,
 CONSTRAINT [PK_T_COM_Producto47] PRIMARY KEY NONCLUSTERED 
(
	[Co_Producto] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicio]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetallePlanServicio](
	[Co_Plan] [int] NOT NULL,
	[Co_itemPlan] [int] IDENTITY(1,1) NOT NULL,
	[Co_Servicio] [int] NOT NULL,
	[Fe_Inicio] [datetime] NOT NULL,
	[Fe_Fin] [datetime] NOT NULL,
	[Fe_HoraInicio] [datetime] NOT NULL,
	[Fe_HoraFin] [datetime] NOT NULL,
	[Tx_Descripcion] [varchar](255) NULL,
 CONSTRAINT [PK_T_SER_ESI_DetallePlanServicio56] PRIMARY KEY NONCLUSTERED 
(
	[Co_Plan] ASC,
	[Co_itemPlan] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [TC_T_SER_ESI_DetallePlanServicio128] UNIQUE NONCLUSTERED 
(
	[Co_Servicio] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Respuesta]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Respuesta](
	[Co_Encuesta] [int] NOT NULL,
	[Co_Seccion] [int] NOT NULL,
	[Co_Pregunta] [int] NOT NULL,
	[Co_Alternativa] [int] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Respuesta64] PRIMARY KEY NONCLUSTERED 
(
	[Co_Alternativa] ASC,
	[Co_Encuesta] ASC,
	[Co_Seccion] ASC,
	[Co_Pregunta] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicioReserva]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetallePlanServicioReserva](
	[Co_Plan] [int] NOT NULL,
	[Co_itemPlan] [int] NOT NULL,
	[Co_Reserva] [int] NOT NULL,
 CONSTRAINT [PK_T_466] PRIMARY KEY NONCLUSTERED 
(
	[Co_Reserva] ASC,
	[Co_Plan] ASC,
	[Co_itemPlan] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Asistencia]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Asistencia](
	[Co_Reserva] [int] NOT NULL,
	[Co_Asistencia] [int] IDENTITY(1,1) NOT NULL,
	[Fe_Asistencia] [datetime] NOT NULL,
	[Fe_HoraAsistencia] [datetime] NOT NULL,
	[Fl_Asistencia] [bit] NOT NULL,
	[No_Estado] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Asistencia57] PRIMARY KEY NONCLUSTERED 
(
	[Co_Reserva] ASC,
	[Co_Asistencia] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [TC_T_SER_ESI_Asistencia103] UNIQUE NONCLUSTERED 
(
	[Co_Reserva] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SOC_ESI_Titular]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SOC_ESI_Titular](
	[Co_Persona] [int] NOT NULL,
	[No_DocIdentidad] [varchar](255) NOT NULL,
	[T_SOC_ESI_Titular_Co_Persona] [int] NULL,
	[T_SOC_ESI_Titular_No_DocIdentidad] [varchar](255) NULL,
	[Fe_Inscripcion] [datetime] NOT NULL,
	[Nu_Invitados] [int] NULL,
	[No_Estado] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SOC_ESI_Titular70] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC,
	[No_DocIdentidad] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_PER_MCO_Personal]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_PER_MCO_Personal](
	[Fe_Ingreso] [smallint] NOT NULL,
	[Tx_Cuenta] [smallint] NOT NULL,
	[Co_Persona] [int] NOT NULL,
	[No_DocIdentidad] [varchar](255) NOT NULL,
	[T_PER_MCO_Personal_Co_Persona] [int] NOT NULL,
	[T_PER_MCO_Personal_No_DocIdentidad] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_PER_MCO_Personal71] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC,
	[No_DocIdentidad] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleFormulario]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetalleFormulario](
	[Co_Servicio] [int] NOT NULL,
	[Co_Encuesta] [int] NOT NULL,
	[Co_Formulario] [int] NOT NULL,
	[Co_Alternativa] [int] NOT NULL,
	[T_SER_ESI_Respuesta_Co_Encuesta] [int] NOT NULL,
	[Co_Seccion] [int] NOT NULL,
	[Co_Pregunta] [int] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_DetalleFormulario65] PRIMARY KEY NONCLUSTERED 
(
	[Co_Formulario] ASC,
	[Co_Encuesta] ASC,
	[Co_Servicio] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_Juridica]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_Juridica](
	[No_Ruc] [varchar](11) NOT NULL,
	[Tx_RazonSocial] [varchar](255) NOT NULL,
	[Tx_Contacto] [varchar](255) NOT NULL,
	[Co_Persona] [int] NOT NULL,
 CONSTRAINT [PK_T_Juridica51] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC,
	[No_Ruc] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_Natural]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_Natural](
	[No_DocIdentidad] [varchar](255) NOT NULL,
	[No_Nombre] [varchar](255) NOT NULL,
	[No_ApellidoMaterno] [varchar](255) NOT NULL,
	[No_ApellidoPaterno] [varchar](255) NOT NULL,
	[Fe_Nacimiento] [datetime] NOT NULL,
	[Fl_Sexo] [varchar](255) NOT NULL,
	[Co_Persona] [int] NOT NULL,
 CONSTRAINT [PK_T_Natural50] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC,
	[No_DocIdentidad] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Pregunta]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Pregunta](
	[Co_Encuesta] [int] NOT NULL,
	[Co_Seccion] [int] NOT NULL,
	[Co_Pregunta] [int] IDENTITY(1,1) NOT NULL,
	[No_Nombre] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Pregunta62] PRIMARY KEY NONCLUSTERED 
(
	[Co_Encuesta] ASC,
	[Co_Seccion] ASC,
	[Co_Pregunta] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Convocatoria]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Convocatoria](
	[Co_Convocatoria] [int] IDENTITY(1,1) NOT NULL,
	[Co_Servicio] [int] NULL,
	[No_Titulo] [varchar](255) NOT NULL,
	[Fe_Inicio] [datetime] NOT NULL,
	[Fe_Fin] [datetime] NOT NULL,
	[Tx_RutaBase] [varchar](255) NULL,
	[Ss_Monto] [money] NOT NULL,
	[Tx_Observacion] [varchar](255) NULL,
	[No_Estado] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Convocatoria40] PRIMARY KEY NONCLUSTERED 
(
	[Co_Convocatoria] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicio]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetalleServicio](
	[Co_Servicio] [int] IDENTITY(1,1) NOT NULL,
	[Qt_Cantidad] [int] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_DetalleServicio59] PRIMARY KEY NONCLUSTERED 
(
	[Co_Servicio] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Formulario]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Formulario](
	[Co_Servicio] [int] NOT NULL,
	[Co_Encuesta] [int] NOT NULL,
	[Co_Formulario] [int] NOT NULL,
	[Fe_Fecha] [datetime] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Formulario60] PRIMARY KEY NONCLUSTERED 
(
	[Co_Formulario] ASC,
	[Co_Encuesta] ASC,
	[Co_Servicio] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Servicio]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Servicio](
	[Co_Servicio] [int] IDENTITY(1,1) NOT NULL,
	[Co_TipoServicio] [int] NOT NULL,
	[Co_Convocatoria] [int] NULL,
	[Tx_Descripcion] [varchar](255) NULL,
	[Ss_MontoPenalidad] [money] NOT NULL,
	[Fl_Reservable] [bit] NOT NULL,
	[Fl_Tercerizable] [bit] NOT NULL,
	[Fl_Activo] [bit] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Servicio42] PRIMARY KEY NONCLUSTERED 
(
	[Co_Servicio] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [TC_T_SER_ESI_Servicio85] UNIQUE NONCLUSTERED 
(
	[Co_Convocatoria] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_ReservaServicio]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_ReservaServicio](
	[Co_Reserva] [int] IDENTITY(1,1) NOT NULL,
	[Co_Persona] [int] NOT NULL,
	[No_DocIdentidad] [varchar](255) NOT NULL,
	[Fe_Reserva] [datetime] NOT NULL,
	[Fe_HoraInicio] [datetime] NULL,
	[Fe_HoraFin] [datetime] NULL,
	[No_Estado] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_ReservaServicio45] PRIMARY KEY NONCLUSTERED 
(
	[Co_Reserva] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleConvocatoria]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetalleConvocatoria](
	[Co_Convocatoria] [int] NOT NULL,
	[Co_Persona] [int] NOT NULL,
	[No_Ruc] [varchar](11) NOT NULL,
	[Fl_Ganador] [bit] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_DetalleConvocatoria] PRIMARY KEY CLUSTERED 
(
	[Co_Convocatoria] ASC,
	[Co_Persona] ASC,
	[No_Ruc] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_COM_CatalagoProveedor]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_COM_CatalagoProveedor](
	[Tx_Rubro] [varchar](255) NOT NULL,
	[Fl_Postor] [varchar](255) NOT NULL,
	[Co_Persona] [int] NOT NULL,
	[No_Ruc] [varchar](11) NOT NULL,
 CONSTRAINT [PK_T_COM_CatalagoProveedor72] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC,
	[No_Ruc] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Expediente]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Expediente](
	[Co_Expediente] [int] IDENTITY(1,1) NOT NULL,
	[Co_Convocatoria] [int] NOT NULL,
	[Co_Persona] [int] NOT NULL,
	[No_Ruc] [varchar](11) NOT NULL,
	[Fe_Recepcion] [datetime] NOT NULL,
	[Tx_Observacion] [varchar](255) NULL,
 CONSTRAINT [PK_T_SER_ESI_Expediente43] PRIMARY KEY NONCLUSTERED 
(
	[Co_Expediente] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_T_SER_ESI_Expediente] UNIQUE NONCLUSTERED 
(
	[Co_Convocatoria] ASC,
	[Co_Persona] ASC,
	[No_Ruc] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Anexo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Anexo](
	[Co_Expediente] [int] NOT NULL,
	[Co_Anexo] [int] IDENTITY(1,1) NOT NULL,
	[Fe_Recepcion] [datetime] NOT NULL,
	[Tx_Observacion] [varchar](255) NULL,
 CONSTRAINT [PK_T_SER_ESI_Anexo38] PRIMARY KEY NONCLUSTERED 
(
	[Co_Expediente] ASC,
	[Co_Anexo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Penalidad]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Penalidad](
	[Co_Penalidad] [int] IDENTITY(1,1) NOT NULL,
	[Co_Reserva] [int] NOT NULL,
	[Co_Asistencia] [int] NOT NULL,
	[Fe_Fecha] [datetime] NOT NULL,
	[No_Estado] [varchar](255) NOT NULL,
	[Ss_Monto] [money] NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Penalidad55] PRIMARY KEY NONCLUSTERED 
(
	[Co_Penalidad] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [TC_T_SER_ESI_Penalidad118] UNIQUE NONCLUSTERED 
(
	[Co_Reserva] ASC,
	[Co_Asistencia] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicioPersonal]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetallePlanServicioPersonal](
	[Co_Plan] [int] NOT NULL,
	[Co_itemPlan] [int] NOT NULL,
	[Co_Persona] [int] NOT NULL,
	[No_DocIdentidad] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_567] PRIMARY KEY NONCLUSTERED 
(
	[Co_Persona] ASC,
	[No_DocIdentidad] ASC,
	[Co_Plan] ASC,
	[Co_itemPlan] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicioAmbiente]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetalleServicioAmbiente](
	[Co_Servicio] [int] NOT NULL,
	[Co_Ambiente] [smallint] NOT NULL,
 CONSTRAINT [PK_T_769] PRIMARY KEY NONCLUSTERED 
(
	[Co_Servicio] ASC,
	[Co_Ambiente] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicioProducto]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_DetalleServicioProducto](
	[Co_Servicio] [int] NOT NULL,
	[Co_Producto] [smallint] NOT NULL,
 CONSTRAINT [PK_T_668] PRIMARY KEY NONCLUSTERED 
(
	[Co_Servicio] ASC,
	[Co_Producto] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Seccion]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[T_SER_ESI_Seccion](
	[Co_Encuesta] [int] NOT NULL,
	[Co_Seccion] [int] IDENTITY(1,1) NOT NULL,
	[No_Nombre] [varchar](255) NOT NULL,
 CONSTRAINT [PK_T_SER_ESI_Seccion63] PRIMARY KEY NONCLUSTERED 
(
	[Co_Encuesta] ASC,
	[Co_Seccion] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetallePlanServicio51]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicio]'))
ALTER TABLE [dbo].[T_SER_ESI_DetallePlanServicio]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetallePlanServicio51] FOREIGN KEY([Co_Plan])
REFERENCES [dbo].[T_SER_ESI_PlanServicio] ([Co_Plan])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetallePlanServicio69]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicio]'))
ALTER TABLE [dbo].[T_SER_ESI_DetallePlanServicio]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetallePlanServicio69] FOREIGN KEY([Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_DetalleServicio] ([Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Respuesta71]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Respuesta]'))
ALTER TABLE [dbo].[T_SER_ESI_Respuesta]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Respuesta71] FOREIGN KEY([Co_Alternativa])
REFERENCES [dbo].[T_SER_ESI_Alternativa] ([Co_Alternativa])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Respuesta72]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Respuesta]'))
ALTER TABLE [dbo].[T_SER_ESI_Respuesta]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Respuesta72] FOREIGN KEY([Co_Encuesta], [Co_Seccion], [Co_Pregunta])
REFERENCES [dbo].[T_SER_ESI_Pregunta] ([Co_Encuesta], [Co_Seccion], [Co_Pregunta])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_452]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicioReserva]'))
ALTER TABLE [dbo].[T_SER_ESI_DetallePlanServicioReserva]  WITH CHECK ADD  CONSTRAINT [FK_T_452] FOREIGN KEY([Co_Reserva])
REFERENCES [dbo].[T_SER_ESI_ReservaServicio] ([Co_Reserva])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_453]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicioReserva]'))
ALTER TABLE [dbo].[T_SER_ESI_DetallePlanServicioReserva]  WITH CHECK ADD  CONSTRAINT [FK_T_453] FOREIGN KEY([Co_Plan], [Co_itemPlan])
REFERENCES [dbo].[T_SER_ESI_DetallePlanServicio] ([Co_Plan], [Co_itemPlan])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Asistencia54]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Asistencia]'))
ALTER TABLE [dbo].[T_SER_ESI_Asistencia]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Asistencia54] FOREIGN KEY([Co_Reserva])
REFERENCES [dbo].[T_SER_ESI_ReservaServicio] ([Co_Reserva])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SOC_ESI_Titular76]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SOC_ESI_Titular]'))
ALTER TABLE [dbo].[T_SOC_ESI_Titular]  WITH CHECK ADD  CONSTRAINT [FK_T_SOC_ESI_Titular76] FOREIGN KEY([T_SOC_ESI_Titular_Co_Persona], [T_SOC_ESI_Titular_No_DocIdentidad])
REFERENCES [dbo].[T_SOC_ESI_Titular] ([Co_Persona], [No_DocIdentidad])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SOC_ESI_Titular77]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SOC_ESI_Titular]'))
ALTER TABLE [dbo].[T_SOC_ESI_Titular]  WITH CHECK ADD  CONSTRAINT [FK_T_SOC_ESI_Titular77] FOREIGN KEY([Co_Persona], [No_DocIdentidad])
REFERENCES [dbo].[T_Natural] ([Co_Persona], [No_DocIdentidad])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_PER_MCO_Personal80]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_PER_MCO_Personal]'))
ALTER TABLE [dbo].[T_PER_MCO_Personal]  WITH CHECK ADD  CONSTRAINT [FK_T_PER_MCO_Personal80] FOREIGN KEY([T_PER_MCO_Personal_Co_Persona], [T_PER_MCO_Personal_No_DocIdentidad])
REFERENCES [dbo].[T_PER_MCO_Personal] ([Co_Persona], [No_DocIdentidad])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_PER_MCO_Personal82]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_PER_MCO_Personal]'))
ALTER TABLE [dbo].[T_PER_MCO_Personal]  WITH CHECK ADD  CONSTRAINT [FK_T_PER_MCO_Personal82] FOREIGN KEY([Co_Persona], [No_DocIdentidad])
REFERENCES [dbo].[T_Natural] ([Co_Persona], [No_DocIdentidad])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetalleFormulario70]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleFormulario]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleFormulario]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetalleFormulario70] FOREIGN KEY([Co_Formulario], [Co_Encuesta], [Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_Formulario] ([Co_Formulario], [Co_Encuesta], [Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetalleFormulario74]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleFormulario]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleFormulario]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetalleFormulario74] FOREIGN KEY([Co_Alternativa], [T_SER_ESI_Respuesta_Co_Encuesta], [Co_Seccion], [Co_Pregunta])
REFERENCES [dbo].[T_SER_ESI_Respuesta] ([Co_Alternativa], [Co_Encuesta], [Co_Seccion], [Co_Pregunta])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_Juridica79]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_Juridica]'))
ALTER TABLE [dbo].[T_Juridica]  WITH CHECK ADD  CONSTRAINT [FK_T_Juridica79] FOREIGN KEY([Co_Persona])
REFERENCES [dbo].[T_Persona] ([Co_Persona])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_Natural78]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_Natural]'))
ALTER TABLE [dbo].[T_Natural]  WITH CHECK ADD  CONSTRAINT [FK_T_Natural78] FOREIGN KEY([Co_Persona])
REFERENCES [dbo].[T_Persona] ([Co_Persona])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Pregunta73]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Pregunta]'))
ALTER TABLE [dbo].[T_SER_ESI_Pregunta]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Pregunta73] FOREIGN KEY([Co_Encuesta], [Co_Seccion])
REFERENCES [dbo].[T_SER_ESI_Seccion] ([Co_Encuesta], [Co_Seccion])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Convocatoria_T_SER_ESI_Servicio]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Convocatoria]'))
ALTER TABLE [dbo].[T_SER_ESI_Convocatoria]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Convocatoria_T_SER_ESI_Servicio] FOREIGN KEY([Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_Servicio] ([Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetalleServicio48]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicio]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleServicio]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetalleServicio48] FOREIGN KEY([Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_Servicio] ([Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Formulario45]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Formulario]'))
ALTER TABLE [dbo].[T_SER_ESI_Formulario]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Formulario45] FOREIGN KEY([Co_Encuesta])
REFERENCES [dbo].[T_SER_ESI_Encuesta] ([Co_Encuesta])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Formulario46]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Formulario]'))
ALTER TABLE [dbo].[T_SER_ESI_Formulario]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Formulario46] FOREIGN KEY([Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_Servicio] ([Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Servicio62]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Servicio]'))
ALTER TABLE [dbo].[T_SER_ESI_Servicio]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Servicio62] FOREIGN KEY([Co_TipoServicio])
REFERENCES [dbo].[T_SER_ESI_TipoServicio] ([Co_TipoServicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_ReservaServicio75]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_ReservaServicio]'))
ALTER TABLE [dbo].[T_SER_ESI_ReservaServicio]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_ReservaServicio75] FOREIGN KEY([Co_Persona], [No_DocIdentidad])
REFERENCES [dbo].[T_SOC_ESI_Titular] ([Co_Persona], [No_DocIdentidad])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetalleConvocatoria_T_COM_CatalagoProveedor]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleConvocatoria]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleConvocatoria]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetalleConvocatoria_T_COM_CatalagoProveedor] FOREIGN KEY([Co_Persona], [No_Ruc])
REFERENCES [dbo].[T_COM_CatalagoProveedor] ([Co_Persona], [No_Ruc])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_DetalleConvocatoria61]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleConvocatoria]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleConvocatoria]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_DetalleConvocatoria61] FOREIGN KEY([Co_Convocatoria])
REFERENCES [dbo].[T_SER_ESI_Convocatoria] ([Co_Convocatoria])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_COM_CatalagoProveedor84]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_COM_CatalagoProveedor]'))
ALTER TABLE [dbo].[T_COM_CatalagoProveedor]  WITH CHECK ADD  CONSTRAINT [FK_T_COM_CatalagoProveedor84] FOREIGN KEY([Co_Persona], [No_Ruc])
REFERENCES [dbo].[T_Juridica] ([Co_Persona], [No_Ruc])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Expediente_T_SER_ESI_Contrato]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Expediente]'))
ALTER TABLE [dbo].[T_SER_ESI_Expediente]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Expediente_T_SER_ESI_Contrato] FOREIGN KEY([Co_Expediente])
REFERENCES [dbo].[T_SER_ESI_Contrato] ([Co_Expediente])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Expediente_T_SER_ESI_DetalleConvocatoria]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Expediente]'))
ALTER TABLE [dbo].[T_SER_ESI_Expediente]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Expediente_T_SER_ESI_DetalleConvocatoria] FOREIGN KEY([Co_Convocatoria], [Co_Persona], [No_Ruc])
REFERENCES [dbo].[T_SER_ESI_DetalleConvocatoria] ([Co_Convocatoria], [Co_Persona], [No_Ruc])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Anexo49]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Anexo]'))
ALTER TABLE [dbo].[T_SER_ESI_Anexo]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Anexo49] FOREIGN KEY([Co_Expediente])
REFERENCES [dbo].[T_SER_ESI_Expediente] ([Co_Expediente])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Penalidad63]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Penalidad]'))
ALTER TABLE [dbo].[T_SER_ESI_Penalidad]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Penalidad63] FOREIGN KEY([Co_Reserva], [Co_Asistencia])
REFERENCES [dbo].[T_SER_ESI_Asistencia] ([Co_Reserva], [Co_Asistencia])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_558]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicioPersonal]'))
ALTER TABLE [dbo].[T_SER_ESI_DetallePlanServicioPersonal]  WITH CHECK ADD  CONSTRAINT [FK_T_558] FOREIGN KEY([Co_Plan], [Co_itemPlan])
REFERENCES [dbo].[T_SER_ESI_DetallePlanServicio] ([Co_Plan], [Co_itemPlan])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_581]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetallePlanServicioPersonal]'))
ALTER TABLE [dbo].[T_SER_ESI_DetallePlanServicioPersonal]  WITH CHECK ADD  CONSTRAINT [FK_T_581] FOREIGN KEY([Co_Persona], [No_DocIdentidad])
REFERENCES [dbo].[T_PER_MCO_Personal] ([Co_Persona], [No_DocIdentidad])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_767]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicioAmbiente]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleServicioAmbiente]  WITH CHECK ADD  CONSTRAINT [FK_T_767] FOREIGN KEY([Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_DetalleServicio] ([Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_768]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicioAmbiente]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleServicioAmbiente]  WITH CHECK ADD  CONSTRAINT [FK_T_768] FOREIGN KEY([Co_Ambiente])
REFERENCES [dbo].[T_INF_Ambiente] ([Co_Ambiente])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_665]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicioProducto]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleServicioProducto]  WITH CHECK ADD  CONSTRAINT [FK_T_665] FOREIGN KEY([Co_Servicio])
REFERENCES [dbo].[T_SER_ESI_DetalleServicio] ([Co_Servicio])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_666]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_DetalleServicioProducto]'))
ALTER TABLE [dbo].[T_SER_ESI_DetalleServicioProducto]  WITH CHECK ADD  CONSTRAINT [FK_T_666] FOREIGN KEY([Co_Producto])
REFERENCES [dbo].[T_COM_Producto] ([Co_Producto])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_T_SER_ESI_Seccion47]') AND parent_object_id = OBJECT_ID(N'[dbo].[T_SER_ESI_Seccion]'))
ALTER TABLE [dbo].[T_SER_ESI_Seccion]  WITH CHECK ADD  CONSTRAINT [FK_T_SER_ESI_Seccion47] FOREIGN KEY([Co_Encuesta])
REFERENCES [dbo].[T_SER_ESI_Encuesta] ([Co_Encuesta])
